<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_address_device_log';
	$filename = 'admin/admin_address_device_log';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
	require_once $_site->get_handlepath('device');
	$page=request('page',false,true,false,1);
	$pagesize=request('pagesize',false,true,false,60);
	$pagesize = is_numeric($pagesize)?$pagesize:60;
	$data['pid']=request('pid',false,true,false,0);
	$data['state']=request('state',false,true,false,1);
	$data['address']=request('address',true,false,false,0);//作业点id
	$data['no']=request('no',true,false,false,0);
	$data['type']=$type=request('type',true,false,false,1);
	$data['truck']=$truck=request('truck',true,false,false,0);
	$data['dust']=$dust=request('dust',true,false,false,0);
	$data['onload']=$onload=request('onload',true,false,false,0);
	$data['dname']=$dname=request('dname');
	$no_title=request('no_title');
    $gcat=request('gcat',true,false,false,-1);
    if($gcat>-1)$data['gcat']=$gcat=(1==$gcat)?1:0;

	$start_time=$data['start_time']=request('start_time');
	$end_time=$data['end_time']=request('end_time');
	if(empty($start_time) && empty($end_time)){
		$now_time=strtotime(date("Y-m-d",time()));
		$start_time=$data['start_time']=date("Y-m-d H:i:s",$now_time);
		$end_time=$data['end_time']=date("Y-m-d H:i:s",$now_time+86399);
	}

	$cols="id,code";
	$result = device_fun_get_checkin_list_all($data,$cols);
?>
<link rel="stylesheet" type="text/css" href="/static/skin/green/css/list.css?v=v1.00">
<script>
function dataverify(){
	$("#selecbtn").attr('disabled','disabled').val('筛选中...');
	var classname='';
	if($("#datalist tr").length==0){
		$("#selecbtn").val('筛选完毕');
		return;
	}

	$("#datalist tr").each(function(){
        classname=$(this).attr('class');
        if($("."+classname).length==1)
        $(this).remove();
	})

	if($("#datalist tr").length>0){
         $("#clearbtn").show();
	}
	$("#selecbtn").val('筛选完毕');
}
//去除重复数据
var tr_id=0; //数据位置
var _classname='';
var _id=0;
function clearrepeat(){
	if(!confirm('是否开始执行去除重复数据？'))return false;
	$("#clearbtn").attr('disabled','disabled').val('筛选中...');
	gorun();
}

function gorun(){
	if($("#datalist tr:eq("+tr_id+")").length>0){
		_classname=$("#datalist tr:eq("+tr_id+")").attr('class');
	    if($("."+_classname+":eq(1)").length>0){
	    	_id=$("."+_classname+":eq(1)").attr('data');
	    	doajax(_id);
	    }else{
	        tr_id++;
	        gorun();
	    }
	}else{
		$("#clearbtn").val('处理完毕');
	}
}

function doajax(id){
	var url="/handle.php?h=project/delop&id="+id;
     $.post(url,function(res){
        if(res.state==false){
           alert(res.msg);return;
        }

        $("#tr"+id).remove();
        gorun();
     },'json');
}
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：工程项目 > 数据校验</div>
		<div class="main">

			<div class="sos_box">
				<form action="/admin/device_workplace_list" id="search" method='get'>
					<input class="button1" type="button" id="selecbtn" onclick="dataverify();" value="筛选重复数据">
					<input class="button1" style="display:none;" id="clearbtn" type="button" onclick="clearrepeat();" value="去除重复数据">
				</form>
				<div style="clear: both;width:100%;*height:25px;margin:5px 0;">
						<b class="red">提示:</b> 如果筛选完毕后，下列有数据则表明有重复数据，需要执行数据去重操作</div>
			</div>

			<table cellpadding="0" cellspacing="1" border="0" class="table">
			<thead>
				<tr>
					<th align="center">序号</th>
					<th align="center">ID号</th>
					<th align="left">校验码</th>
				</tr>
				</thead>
				<tbody id="datalist">
				<?php
					if($result){
                        $key=0;
						foreach ($result as $v){
                             $key++;
							?>
							<tr class="<?php echo $v['code']; ?>" data="<?php echo $v['id']; ?>" id="tr<?php echo $v['id'];?>">
							    <td align="center"><?php echo $key ;?></td>
								<td align="center"><?php echo $v['id'] ;?></td>
								<td align="left"><?php echo $v['code'] ;?></td>
							</tr>
							<?php
						}
					}
				?>
				</tbody>

			</table>
		</div>
	</div>
</body>
</html>


